<?php

require_once 'social/plugin/service/abstract.php';

class Social_Plugin_Helper_Service
{
    protected $_services = array();

    /**
     * get service instance
     * @param string $name
     * @return Social_Plugin_Service_Abstract
     */
    public function getService($name)
    {
        return isset($this -> _services[$name]) ? $this -> _services[$name] : ($this -> _services[$name] = $this -> _createService($name));
    }

    /**
     * get service abstract
     */
    protected function _createService($name)
    {
        $file = 'social/plugin/service/' . $name . '.php';

        require_once $file;

        $class = 'Social_Plugin_Service_' . ucfirst($name);
        return new $class;
    }

}
